import caurina.transitions.Tweener;

class BotonTransicion extends MovieClip {
	var _activo:Boolean;

	function BotonTransicion() {
	}
	
	function set_activo(activo) {
		_activo = activo;
	}
	
	function onLoad() {
		trace("BotonTransicion.onLoad");
		this["encendido"]._visible = false;
		this["encendido"]._alpha = 0;
		(new Color(this["apagado"]["titulo"])).setRGB(0xffffff);
	}
	
	function onRollOver() {
		trace("onRollOver");
		Tweener.removeTweens(this["apagado"]);
		Tweener.removeTweens(this["encendido"]);
		this["encendido"]._visible = true;
		trace(this["encendido"]._alpha);
		Tweener.addTween(this["encendido"], {_alpha: 100, delay: 0, time: 2, transition: "easeInSane"});
		//Tweener.addTween(this["apagado"], {_alpha: 0, delay: 0, time: 0.5, transition: "easeInSane", onComplete: this.no_visible});

		var snd:Sound = new Sound();
		snd.attachSound("catalogo_posar");
		snd.start();
	}
	
	function onRollOut() {
		if(!_activo) {
			Tweener.removeTweens(this["apagado"]);
			Tweener.removeTweens(this["encendido"]);
			this["apagado"]._visible = true;
			//Tweener.addTween(this["apagado"], {_alpha: 100, delay: 0, time: 0.5, transition: "easeInSane"});
			Tweener.addTween(this["encendido"], {_alpha: 0, delay: 0, time: 2, transition: "easeInSane", onComplete: this.no_visible});
		}
	}
	
	function onRelease() {
		var snd:Sound = new Sound();
		snd.attachSound("catalogo_click");
		snd.start();
	}
	
	function onReleaseOutside() {
		onRollOut();
	}
	
	function no_visible() {
		//trace(this);
		this._visible = false;
	}
}